<template>
<!-- 	<view class="kxzcdfer pd pt20 pm20 display-flex cen">
		<view class="fz30 flex-1 z9 " v-for="(item,idx) in immxer" @tap="kmmxcffg(idx)">
			<text class="pr" :class="kmxczxf==idx?'dsfsdrtxr':''">{{item}}</text>
		</view>
	</view> -->

	<view class="pd pm100">
		<template v-for="(item,idx) in jnxzcf">
			
		
		<view class="cdvcxdvrtecxrt pd pt20 pm20 mt20" v-if="!item.isJob">
			<view class="fz32 tlddq" @tap="hf('/pages/index/jobDetails?id='+item.jobId)">
				{{item.jobName}}
			</view>
			<view class="mt10" @tap="hf('/pages/enterprise/details?id='+item.companyId)">
				<text class="iconfont icon-gongsi"></text>
				<text class="z9 fz26 ml5">{{item.companyName}} </text>
			</view>
			<view class="mt20  display-flex fz24">
				<view class=" xzczfsderxct">
					姓名: <text class="z9">{{item.realName}}</text>
				</view>
				<view class=" flex-1 jzhh">
					联系方式: <text class="z9">{{item.userMobile}}</text>
				</view>
				<view class="ml20  tr" v-if="item.inviteRealName">
					邀请人: <text class="z9">{{item.inviteRealName}}</text>
				</view>
			</view>

			<view class="mt10  display-flex fz24">
			<!-- 	<view class=" flex-1">
					审核状态: <text class="z9">{{kmxzcf(item.status)}}</text>
				</view> -->
				<view class="">
					报名时间:<text class="z9">{{item.createTime}} </text>

				</view>

			</view>
			<view class="mt10  display-flex fz24" v-if="item.status==3">
				审核原因: <text class="z9">{{item.statusContent}}</text>
			</view>
			<view class="btm display-flex mt20 pt20 fz30" >
				<view class=" flex-1 ls cen brm" @tap="shenher(item)">
					审核
				</view>
				<view class=" flex-1 red  cen" @tap="dkmxdffdf(idx,item)">
					删除
				</view>
			</view>
		</view>
		</template>
		<view class="vertical-center mt100" v-if="jnxzcf.length<=0">
			<image src="../../static/img/noData.png" class="xczxcertfdgtrr"></image>
			<view class="mt20 z9 fz24">
				暂无数据!
			</view>
		</view>
	</view>

	<view class="shmmxczrt vertical-center" v-if="kmxcfer">
		<view class="kxcztrxett">
			<view class="pd pt20 pm20">
				<text class="kkxczxerwt">审核</text>
			</view>
			<view class="btm kxczzxerxzsrt">
				<view class="pd pt20">
			<!-- 		<radio-group @change="radioChange" class="">
						<label class="xzczxctrt mr20" v-for="(item, index) in items" :key="item.dictValue">
							<view class="display-flex">
								<view>
									<radio :value="item.dictValue" class="kcxzvxcdrytr"/>
								</view>
								<view class="fz28 fgfdgdfgbty">{{item.dictLabel}}</view>
							</view>
						</label>

					</radio-group> -->
				<!-- 	<view class="mt20 pm20" v-if="gxsdr.status==3">
						<textarea v-model="gxsdr.statusContent" class="kxzczxretxctyt fz28" placeholder="请输入不通过的原因"></textarea>
					</view> -->
					<input v-model="gxsdr.companyNo" type="text" placeholder="请输入员工编号" class="w100 kxcxzrert" />
				</view>
			</view>
			<view class="btm pt20 pm20 display-flex cen fz30">
				<view class="flex-1 ls" @tap="kxcxfert">
					确认
				</view>
				<view class="flex-1 red blm" @tap="kmxcfer=false">
					关闭
				</view>
			</view>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { onLoad, onReachBottom } from "@dcloudio/uni-app"
	import { dxrequest, kmxzcf, hf,transferTimeYMD } from "@/util/index.js"
	const page = ref(1)
	const jnxzcf = ref([])
	const kmxczxf = ref(0)
	const status = ref(0)
	const immxer = ref(['全部', '待审核', '审核通过', '审核不通过'])
	const  kxcerrt = ref()
	const kmxcfer = ref(false)
	const dxsd = ref({})
	const gxsdr =ref({
		id:"",
		isJob:true,
		companyNo:"",
		companyTime:transferTimeYMD(new Date())
		
	})
	const items = ref(
		[
			{
				dictValue: 2,
				dictLabel: "通过"
			},
			{
				dictValue: 3,
				dictLabel: "不通过"
			},
		]
	)
	const init = async () => {
		uni.showLoading({
			title: "加载中..."
		})
		const { data } = await dxrequest("/api/jobregist/page", {
			page: page.value,
			limit: 10,
			status: 2,
			isJob:false
		})
		data.list.map(a => {
			jnxzcf.value.push(a)
		})
		uni.hideLoading()
		uni.stopPullDownRefresh();
	}
	onLoad(() => {
		init()
	})
	const kmmxcffg = (idx) => {
		jnxzcf.value = []
		page.value = 1
		kmxczxf.value = idx
		status.value = idx
		init()
	}
	onReachBottom(() => {
		page.value++
		init()
	})
	const dessdf = async (id) => {
		const ret = await dxrequest("/api/jobregist", [id], "DELETE")
	}
	const dkmxdffdf = (idx, data) => {
		uni.showModal({
			title: "温馨提示！",
			content: "确认删除嘛？删除后无法恢复哦！",
			async success({ confirm }) {
				if (confirm) {
					await dessdf(data.id)
					jnxzcf.value.splice(idx, 1)
				}
			}
		})
	}
	const radioChange = (data)=>{
		console.log(data)
		gxsdr.value.status = data.detail.value
	}
	const shenher = (item)=>{
		gxsdr.value.id=item.id
		gxsdr.value.isJob = true
		gxsdr.value.companyTime=transferTimeYMD(new Date()) 
		gxsdr.value.companyNo = ""
		kmxcfer.value = true
		dxsd.value = item
	}
	const kxcxfert = async()=>{
		if(!gxsdr.value.companyNo){
			uni.showToast({
				title:"请输入员工编号",
				icon:"none"
			})
			return
		}
		await dxrequest("/api/jobregist", gxsdr.value, "put")
		dxsd.value.isJob = true
		kmxcfer.value = false
	}
</script>

<style scoped>
	
</style>